import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:verse_systems/utils/image_utils.dart';

typedef OnTapCard = void Function(int index);

class CustomizeMineCard extends StatelessWidget {
  final OnTapCard onTapCard;
  const CustomizeMineCard({super.key, required this.onTapCard});

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(
          horizontal: (MediaQuery.of(context).size.width - 330.w) / 2,
          vertical: 15.w),
      width: 330.w,
      height: 161.w,
      decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(10.w)),
          color: Colours.app_main_color,
          boxShadow: [
            BoxShadow(
                color: Colours.stringAnAlphaColor("0xff000000", alpha: 0.09),
                offset: const Offset(0.0, 15.0), //阴影xy轴偏移量
                blurRadius: 25.0, //阴影模糊程度
                spreadRadius: 0.5 //阴影扩散程度
                )
          ]),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            margin: EdgeInsets.fromLTRB(20.w, 18.w, 0, 0),
            child: Text(
              "service_area".tr,
              style: TextStyle(
                  fontSize: 21.sp,
                  color: Colours.app_text_color,
                  fontWeight: FontWeight.w500),
            ),
          ),
          Container(
              // color: Colors.orange,
              margin: EdgeInsets.fromLTRB(20.w, 30.w, 20.w, 30.w),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: _mineCard,
              ))
        ],
      ),
    );
  }

  List<Widget> get _mineCard {
    return [
      {
        "index": 0,
        "title": "my_orders".tr,
        "url": ImageUtils.getImgPath("mien_order"),
      },
      {
        "index": 1,
        "title": "my_draws".tr,
        "url": ImageUtils.getImgPath("mien_lottery"),
      },
      {
        "index": 2,
        "title": "about_us".tr,
        "url": ImageUtils.getImgPath("mien_aboutUs"),
      },
      {
        "index": 3,
        "title": "questions".tr,
        "url": ImageUtils.getImgPath("mien_question"),
      }
    ].map((val) {
      return InkWell(
          onTap: () {
            onTapCard(int.parse(val["index"].toString()));
          },
          child: Column(
            children: [
              Image.asset(
                val["url"].toString(),
                fit: BoxFit.fill,
                width: 30.w,
                height: 30.w,
              ),
              SizedBox(height: 5.w),
              Text(
                val["title"].toString(),
                style: TextStyle(
                    fontSize: 12.sp,
                    color: Colours.app_text_color,
                    fontWeight: FontWeight.w500),
              ),
            ],
          ));
    }).toList();
  }
}
